<?php
    class Dashboard_Controller extends Application {
        
        function setup()
        {
            $this->actions = array('index');
            $this->use_layout('admin_layout.php');
            $this->before_filter('is_logged_in');
        }
        
		function index() 
		{
		    use_model('news','pages','inbox_leads','inbox');
		    
		    $news = new News();
		    $news_items = $news->find_rows(array('order'=>'created desc',
		                                    'limit'=>6,
		                                    'fields'=>array('id','title','created')
		                                    )
		                              );
		    $this->assign('news',$news_items);
		    
		    $pages = new Pages();
		    $pages_items = $pages->find_rows(array('order'=>'created desc',
		                                      'limit'=>6,
                                              'fields'=>array('id','title','created')
                                              )
                                        );
		    $this->assign('pages',$pages_items);
		    
		    $inbox = new Inbox_Leads();
		    $leads = $inbox->find_rows(array('order'=>'created desc',
		                                'limit'=>6,
                                        'fields'=>array('id','first_name','last_name','created','email')
                                       )
                                  );
		    $this->assign('leads',$leads);
		    
		    $inbox_forms = new Inbox();
		    $forms = $inbox_forms->find_rows(array(
		                                      'fields'=>'id'
		                                      )
		                               );
		    $this->assign('forms',$forms);
		}

        
    }

?>